<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>添加借阅记录</title>
  <meta name="renderer" content="webkit">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
  <link rel="stylesheet" href="../../layuiadmin/layui/css/layui.css" media="all">
  <link rel="stylesheet" href="../../layuiadmin/style/admin.css" media="all">
</head>
<style>
	.selectrecord{
			background-image: url(../../images/record/2019-11-01_154437.png);
			height: 33px;
			width: 568px;
			text-align: left;
		}
	.selectcase{
		background-image: url(../../images/record/snipaste_20191113_211207.png);
		height: 30px;
		width: 550px;
		text-align: left;
	}
</style>
<body>
<form method="post" id="form1">
  <label><font size="4" style="font-weight:bold;"> |  档案借阅管理</font></label>
 	
 	<div class="layui-form" lay-filter="layuiadmin-app-form-list" id="layuiadmin-app-form-list" style="padding: 20px 30px 0 0;">
    
    <div class="layui-form-item">
      <label class="layui-form-label"><font color="red">*</font>案件:</label>
      <div class="layui-input-inline">
        <input type="button" id="casechoice1" name="casechoice" onclick="selectCase()" class="selectrecord">
      </div>
    </div>
    
    <div class="layui-form-item">
      <label class="layui-form-label">委托人：</label>
      <div class="layui-input-inline">
      	<input type="text" id="clientname1" name="clientname" style="width: 200px;height: 25px;">
      </div>
      <label class="layui-form-label">承办律师：</label>
      <div class="layui-input-inline">
      	<input type="text" id="caseemp1" name="caseemp" style="width: 200px;height: 25px;">
      </div>
    </div>
    
    <div class="layui-form-item">
      <label class="layui-form-label"><font color="red">*</font>档案号:</label>
      <div class="layui-input-inline">
        <input type="button" id="record1" name="record" onclick="selectrecord1()" class="selectcase">
      </div>
    </div>
    
    <div class="layui-form-item">
      <label class="layui-form-label"><font color="red">*</font>档案名称:</label>
      <div class="layui-input-inline">
        <input type="text" id="borrowname1" name="borrowname" class="layui-input">
      </div>
      <label class="layui-form-label"><font color="red">*</font>借阅人:</label>
      <div class="layui-input-inline">
        <input type="button" id="empname1" name="empname" onclick="selectborrowemp()" class="selectcase">
      </div>
    </div>
    
    <div class="layui-form-item">
      <label class="layui-form-label"><font color="red">*</font>借出时间:</label>
      <div class="layui-input-inline">
        <input type="text" id="outoftime1" name="outoftime" placeholder="yyyy-MM-dd" lay-verify="date" class="layui-input">
      </div>
      <label class="layui-form-label"><font color="red">*</font>归还时间:</label>
      <div class="layui-input-inline">
        <input  id="returntime1" name="returntime" class="layui-input" type="text" placeholder="yyyy-MM-dd" autocomplete="off" lay-verify="date">
      </div>
    </div>
    
    <div class="layui-form-item">
      <label class="layui-form-label">备注:</label>
      <div class="layui-input-inline">
        <textarea name="content" id="remark1" name="remark" lay-verify="required" style="width: 550px; height: 20px;" autocomplete="off" class="layui-textarea"></textarea>
     	<font size="3">"</font><font color="red">*</font><font size="3">" 代表必填项</font>
      </div><br>
      
    </div><br>
   	<!--客户类型（详细）-->
    <div class="layui-form-item">
    	<label class="layui-form-label"> </label>
		<input type="button" value="确定提交" id="present" onclick="paresentborrow()" class="layui-btn layui-btn-normal">
    </div>
   
   
  </div>
</form>
  <script src="../../layuiadmin/layui/layui.js"></script>
  <script src="../../layuiadmin/jquery/jquery.min.js" type="text/javascript"></script>
  <script>
  	layui.use(['form', 'laydate','upload'], function(){
  			var $ = layui.jquery
            ,upload = layui.upload
            ,form = layui.form
            ,layedit = layui.layedit
            ,laydate = layui.laydate;
        laydate.render({
            elem: '#outoftime1'
        });
        laydate.render({
            elem: '#returntime1'
        });
  	});
$(function(){
		layui.use('form', function(){
        var form = layui.form; 
    	 });
    var parentData=(parent.parentData);	 
    $.ajax({
    	type:"post",
    	url:"http://localhost:8080/borrow/getbyborrow",
    	async:true,
    	data:{"borrowid":parentData.borrowId},
    	success:function(obj){
							$("#casechoice1").val(obj.caseId.caseId),
							$("#record1").val(obj.recordId.recordId),
							$("#empname1").val(obj.empId.empName),
							$("#borrowname1").val(obj.borrowName),
							$("#outoftime1").val(obj.outoftime),
							$("#returntime1").val(obj.returntime),
							$("#remark1").val(obj.remark)

				$.ajax({
				    	type:"post",
				    	url:"http://localhost:8080/borrow/getbycase",
				    	async:true,
				    	data:{"caseId":$("#casechoice1").val()},
				    	success:function(obj){
											$("#clientname1").val(obj.clientId.clientName);
											$("#caseemp1").val(obj.mainLawyer.empName);
								}
		    });
				}
    	
    });
    
    
});
   	function paresentborrow(){
   		var parentData=(parent.parentData);	
		$.ajax({
				type:"post",
				url:"http://localhost:8080/borrow/updateborrow",
				data:{"casechoice":$("#casechoice1").val(),
							"record":$("#record1").val(),
							"empname":$("#empname1").val(),
							"borrowname":$("#borrowname1").val(),
							"outoftime":$("#outoftime1").val(),
							"returntime":$("#returntime1").val(),
							"remark":$("#remark1").val(),
							"borrowid":parentData.borrowId
					},
				async:true,
				success:function(obj){
					if(obj=="ok"){
						var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
						parent.layer.close(index);
						parent.location.reload();
						alert("修改成功!");
					}else{
						alert("修改失败！");
					}
				}
			});
   	}
    function selectCase(){
				layui.use('layer', function(){
				  var layer = layui.layer;
				  layer.open({
                        type: 2,
                        anim: 4,
                        shadeClose:true,
                        title: ['案件选择', 'font-size:18px;'],
                        offset: '10px',
                        area: ['920px', '700px'],
                        content:'record_caseselect.html'
                 });
				});  
				
			}
    function selectrecord1(){
				layui.use('layer', function(){
				  var layer = layui.layer;
				  layer.open({
                        type: 2,
                        anim: 4,
                        shadeClose:true,
                        title: ['档案选择', 'font-size:18px;'],
                        offset: '10px',
                        area: ['920px', '700px'],
                        content:'record_recordselect.html'
                 });
				});  
				
			}
    function selectborrowemp(){
				layui.use('layer', function(){
				  var layer = layui.layer;
				  layer.open({
                        type: 2,
                        anim: 4,
                        shadeClose:true,
                        title: ['借阅人选择', 'font-size:18px;'],
                        offset: '10px',
                        area: ['1350px', '600px'],
                        content:'record_empselect.html'
                 });
				});  
				
			}
    
  </script>
</body>
</html>